from enum import Enum


class PrecisionLevel(Enum):
    LEVEL_00 = (0x00, "0.01")
    LEVEL_01 = (0x01, "0.02")
    LEVEL_02 = (0x02, "0.05")
    LEVEL_03 = (0x03, "0.1")
    LEVEL_04 = (0x04, "0.2")
    LEVEL_05 = (0x05, "0.2S")
    LEVEL_06 = (0x06, "0.5")
    LEVEL_07 = (0x07, "0.5S")
    LEVEL_08 = (0x08, "1")

    @classmethod
    def from_byte(cls, byte_val: int):
        """根据给定的字节值返回对应的精确度等级"""
        for level in cls:
            if level.value[0] == byte_val:
                return level.value[1]
        raise ValueError(f"Unknown precision level for byte: {byte_val}")
